﻿#region Copyright

// Majesty of Omega - The next evolution of macro management space strategy
// 
// Copyright 2007-2009 André Claaßen
// 
// This file is protected by the terms and conditions of the
// Microsoft Community License (Ms-CL 1.1), a copy of which should
// have been distributed along with this software. If not,
// you may find the license information at the following URL:
// 
// http://www.microsoft.com/resources/sharedsource/licensingbasics/communitylicense.mspx

#endregion

#region

using System.Collections.Generic;

#endregion

namespace Majesty_of_Omega.Model.Research
{
    /// <summary>
    /// This Class gives an Info about the tech applications for a given level
    /// </summary>
    /// <remarks>
    /// The purpose of this Class is to 
    /// wrap the <see cref="TechFieldResearch.GetTechApplicationsForLevel"/> function
    /// for databind the grid in the TechnologyMatrixPart.xmal.
    /// </remarks>
    public class TechLevelInfo
    {
        private readonly TechFieldResearch fieldResearch;
        private readonly int level;

        /// <summary>
        /// Initializes a new instance of the <see cref="TechLevelInfo"/> class.
        /// </summary>
        /// <param name="level">The level.</param>
        /// <param name="fieldResearch">The field research.</param>
        public TechLevelInfo(int level, TechFieldResearch fieldResearch)
        {
            this.level = level;
            this.fieldResearch = fieldResearch;
        }

        ///<summary>
        /// The technology Level
        ///</summary>
        public int Level
        {
            get { return level; }
        }

        /// <summary>
        /// The Technology Field
        /// </summary>
        /// <value>The field research.</value>
        public TechFieldResearch FieldResearch
        {
            get { return fieldResearch; }
        }


        /// <summary>
        /// Gets the research progress in percent for this technology level
        /// </summary>
        /// <value>The progress in percent.</value>
        public int ProgressInPercent
        {
            get
            {
                if (this.Level > (this.FieldResearch.TechLevel+1)) return 0;
                if (this.Level == (this.FieldResearch.TechLevel+1))
                    return this.fieldResearch.ProgressInCurrentLevel;
                return 100;
            }
        }

        /// <summary>
        /// Gets the tech application state infos for the level
        /// </summary>
        /// <value>The tech application.</value>
        public IEnumerable<TechApplicationStateInfo> TechApplicationStateInfos
        {
            get { return this.fieldResearch.GetTechApplicationsForLevel(this.level); }
        }
    }
}